package com.four.controller;

import com.four.vo.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @projectName: appointmentsystemfour
 * @package: com.four.controller
 * @className: SchedulingDateController
 * @author: ZZH
 * @description: TODO
 * @date: 2022/10/13 19:19
 * @version: 1.0
 */
@RestController
@RequestMapping("schedulingDate")
public class SchedulingDateController {


    @RequestMapping("schedulingDate")
    public Result schedulingDate(){
        List<String> dates = new ArrayList<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        //使用Calendar
        Calendar calendar = new GregorianCalendar();
        //设置当前时间
        calendar.setTime(new Date());
        for (int i = 0; i < 7; i++) {

            //当前时间往前或者往后推几天 i:负数往前退   正数往后退
            calendar.add(calendar.DATE,i);
            //获取时间
            String s = sdf.format(calendar.getTime());
            dates.add(s);
            //日期会一直累加 所以 在这回退一下
            calendar.add(calendar.DATE,-i);

        }
        return new Result(2000,"success",dates);
    }

}
